<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.*"%>
<%@page import="com.egame.manage.biz.domain.TerminalGroupInfoBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	PageData pd = new PageData();
	if(request.getAttribute("pd") != null){
		pd = (PageData)request.getAttribute("pd");
	}
	
	String terminalGroupName = "";
	if(request.getAttribute("terminalGroupName")!=null) {
		terminalGroupName = (String)request.getAttribute("terminalGroupName");
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet"
	href="<%=request.getContextPath() %>/css/main.css" />
<script type="text/javascript"
	src="<%=request.getContextPath() %>/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/common.js"></script>
<script type="text/javascript">
	function search(){
		$("#searchName").val($.trim($("#searchName").val()));
		document.getElementById("myform").action = "<%=request.getContextPath() + "/tv/terminalgroup/list.do" %>";
		document.getElementById("myform").submit();
	}
	
	function getGroupDetail(id){
		var ok = false;
		$.ajax({			
			url : "<%=request.getContextPath() + "/tv/terminalgroup/detail.do" %>",
			type : 'post',
			data : {
				'id' : id
			},
			success:function (data) {
				if (data && data.retCode == "success") {
					$("#groupName").empty();
					$("#groupName").append("<span>"+data.terminalGroupInfoBean.name+"</span>");
					$("#terminalNames").empty();
					$.each(data.terminalInfos, function (i, item) {
						$("#terminalNames").append("<div>"+item.uacode+"</div>");
					});
					ok = true;
				}
			}, 
			error:function () {
				alert("error");
			},
			async : false
		});
		if(ok){
			setDialog("groupDetail");
		}
	}
	
	function confirmDel(url){
		var confirm = window.confirm("确认删除么?");
		if(confirm){
			window.location.href = url;
		}
	}
	
</script>
<title>机型组列表</title>
</head>
<body>
	<form action="" id="myform">
		<div class="matter_box">
			<h3 class="nopoint"><strong>机型组列表</strong></h3>
			<div class="task_search">
				<span> 机型组名称： 
				<input type=text id="searchName"
					name="terminalGroupName" value="<%=terminalGroupName %>"> <input type=button value="查询" onclick="search()"
					class="upload_btn">
				</span>
			</div>
		
			<p class="tr">
				<a class="btn2"
					href="<%=request.getContextPath() + "/tv/terminalgroup/set/show.do" %>">新增机型组</a>
			</p>
			<div class="mt10 pt10 clearfix">
				<table cellpadding="0" cellspacing="0" class="table2">
					<tr>
						<th>序号</th>
						<th>机型组名称</th>
						<th>已适配终端数</th>
						<th>备注</th>
						<th>操作</th>
					</tr>
					<%
						List<TerminalGroupInfoBean> list = (List<TerminalGroupInfoBean>)pd.getContent();
						if(list != null){
							int i = 1;
							for(TerminalGroupInfoBean bean: list){
								%>
									<tr>
										<td><%=i++ %></td>
										<td><a href = "javascript:getGroupDetail(<%=bean.getId()%>)"><%=bean.getName() %></a></td>
										<td><%=bean.getRelatedCount() %></td>
										<td><%=bean.getRemark() %></td>
										<td>
											<a href="<%=request.getContextPath() + "/tv/terminalgroup/update/show.do?id="+bean.getId() %>">编辑</a>
											<a href="javascript:confirmDel('<%=request.getContextPath() + "/tv/terminalgroup/delete.do?id="+bean.getId() %>')">删除</a>
										</td>
									</tr>
								<%
							}
						}
						
					%>
				</table>
				<%@ include file="../page.in"%>
			</div>
		</div>
	</form>
	<div class="dialog_table editor_group" id="groupDetail" style="width:400px;">
		<h2 class="tc">机型组详情</h2>
			<div style="width: 380px; height: 300px; overflow-y:auto;" >
				<table>
					<tr>
						<td align="left" width="80px">机型组名称:</td>
						<td id="groupName">
							
						</td>
					</tr>
					<tr>
						<td align="left" valign="top" width="80px">已适配终端:</td>
						<td id="terminalNames">
							
						</td>
					</tr>
					
				</table>
			</div>
		</div>
</body>
</html>